<div id="content-container" class="container">
        <img src="/assets/img/zgpa.png" style="width: 100%;">
    <div class="user-section login-section"> 
        <div class="login-main"> 
            <form name="form1" id="buy-form" class="form-vertical" method="POST" action=""> 
                {:token()}

                <div class="form-group"> 
                    <label class="control-label" for="account">请选择产品年限</label>
                    <div class="controls"> 
                            <select id="safe_years" name="safe_years"  onchange="func()"  class="form-control selectpicker"  style="height:3.5em">
                                    <option value="{$safe_year}" data='{$safe_year}'>中国平安汽车GPS盗抢责任险 {$safe_year}年</option> 
                            </select> 
                        <p class="help-block"></p>
                    </div>
                </div>
              <input type='hidden' value="{$ctype}" name='insurance_company' / >

                <div class="form-group"> 
                    <label class="control-label" for="account">大保单号：<b style="color: red">*</b></label>
                    <div class="controls">
                        {if $safe_year eq 1}
                        <input type="text" id="big_number" name="big_number" readonly  class="form-control input-lg" value="11077003900529071292">
                        {elseif $safe_year eq 3}
                        <input type="text" id="big_number" name="big_number" readonly  class="form-control input-lg" value="11077003900613414447">
                        {/if}
                        <p class="help-block"></p>
                    </div>
                </div> 
                <div class="form-group" style="display: none;"> 
                    <label class="control-label" for="account">子保单号：<b style="color: red">*</b></label>
                    <div class="controls"> 
                        <input type="text" id="small_number" name="small_number" readonly class="form-control input-lg" value="{$small_number}"> 
                        <p class="help-block"></p>
                    </div>
                </div>
                <div class="form-group"> 
                    <label class="control-label" for="account">邀请人</label>
                    <div class="controls">
                        <input type="text" id="invite_name"  name="invite_name" data-rule="required;invite_name" class="form-control input-lg" placeholder="请输入邀请人">
                        <p class="help-block"></p>
                    </div>
                </div>
                <div class="form-group"> 
                    <label class="control-label" for="account">新车二手车<b style="color: red">*</b></label>
                    <div class="controls">
                         <select id="car_style" name="car_style" data-rule="" class="form-control selectpicker"   style="height:3.5em"> 
                                    <option value="新车" >新车</option>
                                    <option value="二手车">二手车</option> 
                            </select> 
                        <p class="help-block"></p>
                    </div>
                </div>
                
                
                <div class="form-group">  
                    <label class="control-label" for="account">保险服务费(元)：<b style="color: red">*</b></label>
                    <div class="controls"> 
                        <input type="text" id="fee" name="fee"  class="form-control input-lg" > 
                        <p class="help-block"></p>
                    </div>
                </div>
                <div class="form-group"> 
                    <label class="control-label" for="account">机动车所有人<b style="color: red">*</b>（公户车填写公司名字）</label>
                    <div class="controls">
                        <input type="text" id="real_name" name="real_name" data-rule="required;real_name" class="form-control input-lg" placeholder="请输入机动车所有人（公户车填写公司名字）">
                        <p class="help-block"></p>
                    </div>
                </div>


                
                <div class="form-group"> 
                    <label class="control-label" for="account">证件号<b style="color: red">*</b>（公户车填写统一社会信用代码）</label>
                    <div class="controls">
                        <input type="text" id="card_no" name="card_no" data-rule="required;card_no" class="form-control input-lg" placeholder="请输入证件号（公户车填写统一社会信用代码）">
                        <p class="help-block"></p>
                    </div>
                </div>
                    <div class="form-group"> 
                    <label class="control-label" for="account">移动电话<b style="color: red">*</b>（联系人电话号码）</label>
                    <div class="controls">
                        <input type="text" id="tel" name="tel" data-rule="required;tel" class="form-control input-lg" placeholder="请输入移动电话（联系人电话号码）">
                        <p class="help-block"></p>
                    </div>
                </div>
                <div class="form-group"> 
                    <label class="control-label" for="account">证件地址<b style="color: red">*</b>（公户车填营业执照上的地址）</label>
                    <div class="controls">
                        <input type="text" id="card_address" name="card_address" data-rule="required;card_address" class="form-control input-lg" placeholder="请输入证件地址（公户车填营业执照上的地址）">
                        <p class="help-block"></p>
                    </div>
                </div>
                 <div class="form-group"> 
                    <label class="control-label" for="account">常住地址<b style="color: red">*</b>（实际居住地/办公地）</label>
                    <div class="controls">
                        <input type="text" id="address" name="address" data-rule="required;address" class="form-control input-lg" placeholder="请输入常住地址（实际居住地/办公地）">
                        <p class="help-block"></p>
                    </div>
                </div>


                 <div class="form-group"> 
                    <label class="control-label" for="account"><b style="color: red">*</b>车辆厂牌（车辆品牌）</label>
                    <div class="controls">
                        <input type="text" id="car_number" name="car_number" data-rule="required;car_number" class="form-control input-lg" placeholder="请输入车辆厂牌（车辆品牌）">
                        <p class="help-block"></p>
                    </div>
                </div>

                <div class="form-group"> 
                    <label class="control-label" for="account">车牌号（行驶证上的车牌号）</label>
                    <div class="controls">
                        <input type="text" id="car_no" name="car_no" data-rule="required;car_no" class="form-control input-lg" placeholder="车牌号（行驶证上的车牌号）">
                        <p class="help-block"></p>
                    </div>
                </div>
                <div class="form-group"> 
                    <label class="control-label" for="account">车辆型号<b style="color: red">*</b>（行驶证上的车辆型号）</label>
                    <div class="controls">
                        <input type="text" id="vehicle_model" name="vehicle_model" data-rule="required;vehicle_model " class="form-control input-lg" placeholder="车辆型号（行驶证上的车辆型号）">
                        <p class="help-block"></p>
                    </div>
                </div> 
                <div class="form-group"> 
                    <label class="control-label" for="account">发动机号<b style="color: red">*</b>（（行驶证上的发动机号）</label>
                    <div class="controls">
                        <input type="text" id="engine_number" name="engine_number" data-rule="required;engine_number" class="form-control input-lg" placeholder="发动机号（行驶证上的发动机号）">
                        <p class="help-block"></p>
                    </div>
                </div> 
                <div class="form-group"> 
                    <label class="control-label" for="account">车架号<b style="color: red">*</b>（行驶证上的车架号）</label>
                    <div class="controls">
                        <input type="text" id="frame_number" name="frame_number" data-rule="required; frame_number" class="form-control input-lg" placeholder="车架号（行驶证上的车架号）">
                        <p class="help-block"></p>
                    </div>
                </div> 
                <div class="form-group"> 
                    <label class="control-label" for="account">车辆登记日期（行驶证上的登记日期）</label>
                    <div class="controls">
                        <input type="text" id="dj_time" name="dj_time" readonly data-rule="required;dj_time" class="form-control input-lg" placeholder="车辆登记日期（行驶证上的登记日期）">
                        <p class="help-block"></p>
                    </div>
                </div> 
                 <div class="form-group"> 
                    <label class="control-label" for="account">购买日期（购买合同日期）</label>
                    <div class="controls">
                        <input type="text" id="buy_time" name="buy_time" readonly data-rule="required;buy_time" class="form-control input-lg" placeholder="购买日期（购买合同日期）">
                        <p class="help-block"></p>
                    </div>
                </div> 
                <div class="form-group"> 
                    <label class="control-label" for="account">安装地点（安装的城市）</label>
                    <div class="controls">
                        <input type="text" id="az_address" name="az_address" data-rule="required;az_address" class="form-control input-lg" placeholder="安装地点（安装的城市）">
                        <p class="help-block"></p>
                    </div>
                </div> 
                 <div class="form-group"> 
                    <label class="control-label" for="account">安装人员（安装的人员名字）</label>
                    <div class="controls">
                        <input type="text" id="az_user" name="az_user" data-rule="required;az_user" class="form-control input-lg" placeholder="安装人员（安装的人员名字）">
                        <p class="help-block"></p>
                    </div>
                </div> 

                 <div class="form-group"> 
                    <label class="control-label" for="account">设备ID<b style="color: red">*</b>（GPS定位器设备编码）</label>
                    <div class="controls">
                        <input type="text" id="device_id" name="device_id" data-rule="required;device_id" class="form-control input-lg" placeholder="设备ID（GPS定位器设备编码）">
                        <p class="help-block"></p>
                    </div>
                </div> 
                <div class="form-group"> 
                    <label class="control-label" for="account">车身价（购车合同价格，单位元）</label>
                    <div class="controls">
                        <input type="text" id="car_price" name="car_price" data-rule="required;car_price" class="form-control input-lg" placeholder="车身价（购车合同价格，单位元）">
                        <p class="help-block"></p>
                    </div>
                </div> 
                 <div class="form-group"> 
                    <label class="control-label" for="account">贷款金额（贷款金额，单位元）</label>
                    <div class="controls">
                        <input type="text" id="dk_prrice" name="dk_prrice" data-rule="required;dk_prrice" class="form-control input-lg" placeholder="贷款金额（贷款金额，单位元）">
                        <p class="help-block"></p>
                    </div>
                </div> 
                <div class="form-group"> 
                    <label class="control-label" for="account">第一受益人（理赔时优先理赔对象）</label>
                    <div class="controls">
                        <input type="text" id="beneficiary" name="beneficiary" data-rule="required;beneficiary" class="form-control input-lg" placeholder="第一受益人（理赔时优先理赔对象）">
                        <p class="help-block"></p>
                    </div>
                </div>  

                </div>
                <input type="hidden" name="openid" id="openid" value="{$openid}">
                <div class="form-group"  style="text-align: center;">
                    <!-- <button type="submit" class="btn  btn-danger btn-lg btn-block">立即支付</button> -->
                    <a href="javascript:pay();" class="btn btn-lg btn-danger btn-donate" data-image="https://cdn.fastadmin.net/uploads/donate/karson.png" data-name="third"><i class="fa fa-money"></i> 立即支付</a> 
                </div>
            </form>
        </div>
    </div>
</div>

<script src="/assets/js/jquery-1.8.3.min.js"></script>
<script src="/assets/js/layer/layer.js"></script>
<script src="/assets/js/laydate/laydate.js"></script>
<script type="text/javascript">

laydate.render({
  elem: '#buy_time' //指定元素
});
laydate.render({
  elem: '#dj_time' //指定元素
});
    //手机
var phoneReg = /^1(3|4|5|6|7|8|9)[0-9]\d{8}$/;
//身份证
var idCardReg = /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/;
//金额
var moneyReg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
 

var cardReg = /(^[0-9a-zA-Z]{4,23})/;

var  noReg = /^[0-9]\d{4,20}$/;
    
        function func(){
            var vs = $('#safe_years option:selected').attr('data'); 
            if(vs == 1){
                $('#big_number').val('11077003900545599514');
                // $('#fee').val(600);
            }else if(vs == 2){ 
                $('#big_number').val('22077003900545599514');
                // $('#fee').val(1200);
            }else if(vs == 3){ 
                $('#big_number').val('33077003900545599514');
                // $('#fee').val(1800);
            }   
        }
        function pay(){ 
            if($("#real_name").val()==''){
                layer.msg('请输入车主姓名');
                return;
            }else if(!cardReg.test($('#card_no').val())){
                layer.msg('证件号格式有误');
                return;
            }else if(!phoneReg.test($("#tel").val())){
                layer.msg('移动电话格式有误');
                return;
            }else if($("#card_address").val()==''){
                layer.msg('请输入证件地址');
                return;
            }else if($("#address").val()==''){
                layer.msg('请输入常住地址');
                return;
            }else if($("#car_number").val()==''){
                layer.msg('请输入车辆厂牌');
                return;
            }else if($("#vehicle_model").val()==''){
                layer.msg('请输入车辆型号');
                return;
            }else if(!cardReg.test($("#engine_number").val())){
                layer.msg('发动机号格式有误');
                return;
            }else if($("#frame_number").val()==''){
                layer.msg('请输入车架号');
                return;
            }else if(!noReg.test($("#device_id").val())){
                layer.msg('设备ID格式有误');
                return;
            }else{ 
                $.ajax({
                    type: 'POST',
                    url: "{:url('product/pay')}",
                    data:  $("#buy-form").serialize(),
                    dataType: 'json',
                    beforeSend:function(result){
                       layer.load(1, {shade: [0.5,'#000'] });
                    },
                    success:function(result){  
                       layer.closeAll(); 
                       if(result.code=='200'){
                        var  jsonback = result.data; 
                              if (typeof WeixinJSBridge == "undefined"){
                                if( document.addEventListener ){
                                    document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
                                }else if (document.attachEvent){
                                    document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
                                    document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
                                }
                            }else{
                                WeixinJSBridge.invoke(
                                'getBrandWCPayRequest',
                                JSON.parse(jsonback),
                                    function(res){
                                        if(res.err_msg == "get_brand_wcpay_request:ok" ) {
                                            layer.msg('支付成功');  
                                            location.href="{:url('product/payback')}?out_trade_no="+result.out_trade_no;
                                        }else if(res.err_msg == "get_brand_wcpay_request:cancel" ) {
                                            layer.msg('支付过程中用户取消'); 
                                        }else if(res.err_msg == "get_brand_wcpay_request:fail" ) {
                                            layer.msg('支付失败'); 
                                        }    
                                    }
                                );
                            }
                       }else{
                        layer.msg(result.msg); 
                       }
                    },
                    error:function(data){
                        layer.closeAll();
                        layer.msg('网络异常,请稍后再试'); 
                    }

                }); 
            } 
        } 

</script>






<br><br><br><br><br><br>




















